#!/bin/bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${SCRIPT_DIR}"

REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "${REPO_ROOT}"

DATETIME=$(date +%Y%m%d.%H%M%S)

source /remote/iosg/home/bot-coin/miniconda3/etc/profile.d/conda.sh
conda activate /remote/iosg/home/bot-coin/miniconda3/envs/coin2_motion_env

OUT=$(./pyrunner python/coin2/support/feed_archive/app/symbol_groups_updater.py)
conda deactivate
echo ${OUT}

if [ "${OUT}" == "updated" ]; then
  git checkout -b feature/update-symbol-groups-${DATETIME}
  git add data/
  git commit -m "Update symbol groups and pi ${DATETIME}. This is auto-generated."
  git push -u origin feature/update-symbol-groups-${DATETIME}
  git checkout master
fi
